import 'package:flutter/material.dart';
import 'package:flutter_deer/account/iview/below_user_deposit_score_list_iview.dart';
import 'package:flutter_deer/account/models/user_score_deposit_entity.dart';
import 'package:flutter_deer/mvp/base_page_presenter.dart';
import 'package:flutter_deer/net/base_entity.dart';
import 'package:flutter_deer/net/dio_utils.dart';
import 'package:flutter_deer/net/http_api.dart';
import 'package:flutter_deer/res/constant.dart';
import 'package:flutter_deer/util/other_utils.dart';


class BelowUserDepositScoreListPresenter extends BasePagePresenter<BelowUserDepositScoreListIMvpView> {

  @override
  void initState() {

  }

  Future<dynamic> getDepositScoreList(String? username) async {
    WidgetsBinding.instance.addPostFrameCallback((_) {
      final Map<String, dynamic> params = <String, dynamic>{};
      params['size'] = Constant.pageSize;
      params['current'] = 1;
      requestNetwork<BaseEntity<BelowUserScoreDepositPageEntity>>(Method.get,
          url: HttpApi.belowUserDepositScoreList.replaceAll('{username}', username.nullSafe),
          queryParameters: params,
          onSuccess: (data) {
            view.setBelowUserDepositScorePage(data?.data);
          },
          onError: (code, msg) {

          }
      );
    });
  }

  Future<dynamic> getMoreDepositScoreList(String? username,int? pageNo) async {
    WidgetsBinding.instance.addPostFrameCallback((_) {
      final Map<String, dynamic> params = <String, dynamic>{};
      params['size'] = Constant.pageSize;
      params['current'] = pageNo;
      requestNetwork<BaseEntity<BelowUserScoreDepositPageEntity>>(Method.get,
          url: HttpApi.belowUserDepositScoreList.replaceAll('{username}', username.nullSafe),
          queryParameters: params,
          onSuccess: (data) {
            view.setBelowUserDepositScorePage(data?.data);
          },
          onError: (code, msg) {

          }
      );
    });
  }
}